About 2612 letters

About 13 minutes

#HTML <track>

The <track> HTML element is used as a child of the media elements, <audio> and <video>. Each track element lets you specify a timed text track (or time-based data) that can be displayed in parallel with the media element, for example to overlay subtitles or closed captions on top of a video or alongside audio tracks.

#Attributes

  • default: This attribute indicates that the track should be enabled unless the user's preferences indicate that another track is more appropriate. This may only be used on one track element per media element.

  • kind: How the text track is meant to be used. If omitted the default kind is subtitles. If the attribute contains an invalid value, it will use metadata. The following keywords are allowed:

    • subtitles

      • Subtitles provide translation of content that cannot be understood by the viewer. For example speech or text that is not English in an English language film.
      • Subtitles may contain additional content, usually extra background information. For example the text at the beginning of the Star Wars films, or the date, time, and location of a scene.
    • captions

      • Closed captions provide a transcription and possibly a translation of audio.
      • It may include important non-verbal information such as music cues or sound effects. It may indicate the cue's source (e.g., music, text, character).
      • Suitable for users who are deaf or when the sound is muted.
    • chapters

      • Chapter titles are intended to be used when the user is navigating the media resource.
    • metadata

      • Tracks used by scripts. Not visible to the user.
  • label: A user-readable title of the text track which is used by the browser when listing available text tracks.

  • src: Address of the track (.vtt file). Must be a valid URL. This attribute must be specified and its URL value must have the same origin as the document — unless the <audio> or <video> parent element of the track element has a crossorigin attribute.

  • srclang: Language of the track text data. It must be a valid BCP 47 language tag. If the kind attribute is set to subtitles, then srclang must be defined.

Created in 6/9/2025

Updated in 6/9/2025